package com.pt25.service.sys.repository.mysql.converter;


import com.pt25.base.util.JsonUtil;
import com.pt25.service.sys.domain.admin.ddo.AdminPermission;
import com.pt25.service.sys.domain.admin.ddo.AdminRole;
import com.pt25.service.sys.domain.admin.ddo.AdminUser;
import com.pt25.service.sys.repository.mysql.po.AdminPermissionPo;
import com.pt25.service.sys.repository.mysql.po.AdminRolePo;
import com.pt25.service.sys.repository.mysql.po.AdminUserPo;

public interface AdminConverter {

    static AdminUser adminUserPO2AdminUser(AdminUserPo adminUserPO) {
        return adminUserPO == null ? null : AdminUser.builder().id(adminUserPO.getId())
                .admin(adminUserPO.getAdmin())
                .password(adminUserPO.getPassword())
                .build();
    }

    static AdminRole adminRolePO2AdminRole(AdminRolePo adminRolePO) {
        return adminRolePO == null ? null : AdminRole.builder()
                .id(adminRolePO.getId())
                .role(adminRolePO.getRole())
                .build();
    }

    static AdminPermission adminPermissionPO2AdminPermission(AdminPermissionPo adminPermissionPO) {
        return JsonUtil.toBean(JsonUtil.toJson(adminPermissionPO), AdminPermission.class);
    }
}
